import React, { Component } from 'react';
import Axios from '../../utils/request';
class Login extends Component {
	constructor(props) {
		super(props);
		this.state = {
			username: '', //用户名
			password: '' //登录密码
		};
	}

	username = (e) => {
		// console.log(e.target.value);
		this.setState({ username: e.target.value });
	};
	password = (e) => {
		this.setState({ password: e.target.value });
	};
	//提交登录信息
	submitLogin = () => {
		const { username, password } = this.state;
        console.log(username, password);
        Axios({
            method:'post',
            url:'/enter/login',
            data:{
                account:username,
                password:password
            }
        }).then((res)=>{
            console.log(res);
        })
	};
	render() {
		return (
			<div>
				<p>
					<input type="text" value={this.state.username} onChange={this.username} /> 用户名
				</p>
				<p>
					<input type="password" value={this.state.password} onChange={this.password} /> 密码
				</p>
				<button onClick={this.submitLogin}>登录</button>
			</div>
		);
	}
}

export default Login;
